Testing the DocuGenerate API is made simple with our intuitive API Reference. In this article, we’ll walk through the process using the Sales Contract template from the Template Library to create a template and generate a document.
To start testing the API, you need to authenticate your requests. Head to the Settings page, copy your API Key, then click the Authorize button in the API Reference. Paste the copied Key in the Value
field:
This step automatically populates your API Key in the Authorization
header for all your HTTP requests.
Creating a template is simple. Go to the Create template endpoint and click Try it out:
The only required field is the file
field, where you select a template file in .docx
, .doc
, .odt
, .txt
, or .sql
format. After optionally specifying other values like the template name, or the tag delimiters, click Execute to call the API.
Upon processing, the API returns a JSON object for the newly created template:
{
"enhanced_syntax": false,
"tags": {
"valid": [
"Effective Date",
"Seller Name",
"Seller Address",
"Customer Name",
"Customer Address",
"Item 1",
"Quantity 1",
"Price Per Unit 1",
"Total Price 1",
"Item 2",
"Quantity 2",
"Price Per Unit 2",
"Total Price 2",
"Item 3",
"Quantity 3",
"Price Per Unit 3",
"Total Price 3",
"Item 4",
"Quantity 4",
"Price Per Unit 4",
"Total Price 4",
"Total Amount",
"Delivery Location",
"Shipping Responsible",
"Notice",
"Governing Country"
],
"invalid": []
},
"filename": "Sales Contract.docx",
"created": 1696365709024,
"delimiters": {
"left": "[",
"right": "]"
},
"name": "Sales Contract",
"format": ".docx",
"page_count": 4,
"image_uri": "https://storage.googleapis.com/docugenerate.appspot.com/templates/bO3evhkReKby6uxSY3xa/Sales%20Contract.png?GoogleAccessId=firebase-adminsdk-4i7q5%40docugenerate.iam.gserviceaccount.com&Expires=1727901723&Signature=MhqN0AjYSA7OeazSm0K%2B8P0idgtPYXaUprOghOUWdLxKOIyIdaYytU3vnrmXXC3d%2FGPbkSokp6Y%2BfNwB14VivY8fGbXDQbi8X7CJMuZCB6OQMNf8O9sbqCN5oHnySfKz9fHkP4M4uD%2BboGF41%2BXyfVkDwe637KBbinfDot9wd8uOxpe2R1hfMDql2WbSjYQvTDXYQon1Ao18%2FwlGioKCT8VBfjRIfRTF5mdEvpmUHXm0vzL9tMO8dVsKgx5w%2Fd7x1GU1nFr2J8eLpGJJQunroFeV%2FfmSR30OQjk%2B5VbXmdrLiQJN%2BTsxGdq0qjoMURLEVdYfqvcVPIYJCybuQtYsWg%3D%3D",
"preview_uri": "https://storage.googleapis.com/docugenerate.appspot.com/templates/bO3evhkReKby6uxSY3xa/Sales%20Contract.pdf?GoogleAccessId=firebase-adminsdk-4i7q5%40docugenerate.iam.gserviceaccount.com&Expires=1727901723&Signature=ygANV%2Fs0aG9qd0ofOGxhZ8j%2BemwEF%2BFQoYwL%2FWzpllAYNxPUpjxgWLm6%2B%2F19kcdAC0hd1OV96wmXpL0KLeQDPrkpkR3og3LkyiV78AAEk%2BGfHcf%2B6wmkGcM1QCDgX%2Bj7OeLZdIUWyi0lcX%2FDSJihdWn7JR5tYAlbxOzc6IL77Q1o6YOoQOt1et4v9aYVVjaYhliCV10L1AaIVt%2FXBFDGveKSo1sqUlYip5hhW4fI445U0nltGbdXBa20nxFWMnzNLy06vzU9OW4w3bpwRWdrXP%2BRhvQwCC1xT6sETMfOx8TpSwbhAJkwatqaQhl4e893mzkNWtlrd4LbJNtrk2D4Qw%3D%3D",
"template_uri": "https://storage.googleapis.com/docugenerate.appspot.com/templates/bO3evhkReKby6uxSY3xa/Sales%20Contract.docx?GoogleAccessId=firebase-adminsdk-4i7q5%40docugenerate.iam.gserviceaccount.com&Expires=1727901723&Signature=K8d2R66Uk6d5id3hkDFMHslGzUJN7ylifsxvxbDJcjTRyYiXYmLf6hElYkMgoPe4Cnn9IjAGNuIHbAaFOdk6p0%2Fo9nqp28PST%2F%2Fw%2Fgxt7ugQIqaLyE0pHY6VD6BLtm9OJgiptVFELA6jLG1LbJ%2Fw5%2BtPF7eHXScxJbNaHX42aNTNMSGRVcZu4dxxYdK5o2EWBwKPLmunOBp23w5YtOjFjJqtk%2FNhItilMJRt7EzA61dhaXsqKBVShcUhi6rfa%2Blz209CKOz0waSUmaJWYzhAvliVQkD9oi9gs7Lga0nRrlJtp37%2FqwdpB1F%2FcJjZ%2BuRbLc7QhzAvWd6Iih5HJdVXlA%3D%3D",
"id": "bO3evhkReKby6uxSY3xa"
}
Generating a document is equally straightforward. Go to the Generate document endpoint and click Try it out:
In the template_id
field, specify the ID of the template you want to use. For example, if you want to generate a document from the template created at the previous step, you need to use the bO3evhkReKby6uxSY3xa
template ID.
For the data
input, provide the data set that will be used to generate the documents. The expected format is an array of JSON objects, where each JSON object has the keys corresponding to the template’s merge tags. After entering other values like the document name and output format, click Execute to call the API.
Upon processing, the API returns a JSON object for the newly created document. Within the response object, the document_uri
field provides a link to the generated file:
{
"filename": "Sales Contract.docx",
"created": 1696365915580,
"data_length": 1,
"name": "Sales Contract",
"format": ".docx",
"template_id": "bO3evhkReKby6uxSY3xa",
"document_uri": "https://storage.googleapis.com/docugenerate.appspot.com/documents/7JxcR3Q1EVKqljsTvHqc/Sales%20Contract.docx?GoogleAccessId=firebase-adminsdk-4i7q5%40docugenerate.iam.gserviceaccount.com&Expires=1727901916&Signature=xvAdGTfKVse32ip%2BsLM3soYvSbmb4m%2FoS7G0th8Mv5bbDjtiFvo%2BPXnCczOEdZmD4PhZ1T8v4NfXpovEKrZxe17jH6JC%2BUGZavb5pw2PGbJm5pdEioMBl3JIYU%2Fb06xQyPN%2BNs65wutLCGvOGQdvJDcAkwfj4MtMUPnWY4PsL5i4vv7QRXnGkZzg1GQs3A0YjDqLKjJxqr5A%2Fr2l6hZBBpF5iLR3ACqjvwfF32ZTggIK5tj7EGwDrzLxUpW0U03Ion7Q818F1NHInAp1aivVVYfd3Yn4I2twK9zOj4h%2F8ctzBodIAF%2Fk%2BwN%2F8uliIplu7wbPSuAXel00LVtwmr7sdQ%3D%3D",
"id": "7JxcR3Q1EVKqljsTvHqc"
}
With the API Reference, testing DocuGenerate’s API becomes a seamless experience. Try it out for yourself and explore the possibilities for document generation in your workflow.